package com.example.computer_exam_training_sys.mapper;

import com.example.computer_exam_training_sys.vo.UserFavoriteDetailVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

@Mapper
public interface UserFavoritesVOMapper {
    @Select("SELECT f.id, f.user_id AS userId, u.username, f.question_id AS questionId, q.content AS questionContent, f.create_time AS createTime " +
            "FROM user_favorites f " +
            "LEFT JOIN users u ON f.user_id = u.user_id " +
            "LEFT JOIN questions q ON f.question_id = q.question_id ")
    List<UserFavoriteDetailVO> selectAllUserFavoriteDetails();

    @Select("SELECT f.id, f.user_id AS userId, u.username, f.question_id AS questionId, q.content AS questionContent, f.create_time AS createTime " +
            "FROM user_favorites f " +
            "LEFT JOIN users u ON f.user_id = u.user_id " +
            "LEFT JOIN questions q ON f.question_id = q.question_id " +
            "WHERE f.user_id = #{userId}")
    List<UserFavoriteDetailVO> selectUserFavoriteDetailsByUserId(int userId);
}
